package com.bw.log.impl;

import android.util.Log;

import com.bw.log.ILogger;
import com.bw.log.LoggerLevel;

/**
 * @author:created by hahajing
 * 时间：2024/4/25 0025
 * 企鹅号:444511958
 * 描述:
 */
public class LogcatImpl implements ILogger {

    private String logFormat = "==> %s ---- %s";

    @Override
    public void v(String tag, String log) {
        if (mIsDebug&&LoggerLevel.Verbose.ordinal()>=mLevel.ordinal()){
            Log.v(mTag,String.format(logFormat,tag,log));
        }

    }

    @Override
    public void i(String tag, String log) {
        if (mIsDebug&&LoggerLevel.Info.ordinal()>=mLevel.ordinal()){
            Log.v(mTag,String.format(logFormat,tag,log));
        }
    }

    @Override
    public void d(String tag, String log) {
        if (mIsDebug&&LoggerLevel.Debug.ordinal()>=mLevel.ordinal()){
            Log.v(mTag,String.format(logFormat,tag,log));
        }
    }

    @Override
    public void w(String tag, String log) {
        if (mIsDebug&&LoggerLevel.Warn.ordinal()>=mLevel.ordinal()){
            Log.v(mTag,String.format(logFormat,tag,log));
        }
    }

    @Override
    public void e(String tag, String log) {
        if (mIsDebug&&LoggerLevel.Error.ordinal()>=mLevel.ordinal()){
            Log.v(mTag,String.format(logFormat,tag,log));
        }
    }

    private boolean mIsDebug=false;
    @Override
    public void setDebug(boolean isDebug) {
        mIsDebug=isDebug;
    }

    private String mTag="123";
    @Override
    public void setLogTag(String tag) {
        this.mTag=tag;
    }

    private LoggerLevel mLevel=LoggerLevel.Verbose;
    @Override
    public void setLoggerLevel(LoggerLevel level) {
        this.mLevel=level;
    }
}
